package com.humanres.activity;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.ciko.code.base.BaseActicity;
import com.mywork.R;

import java.io.File;

/**
 * Created by Administrator on 2016/3/29.
 */
public class ResOtherDetailActivity extends BaseActicity {
    private String mTitle;
    private String pdfUrl;
    private WebView               webView;
    @Override
    protected void getIntenData() {
        super.getIntenData();
        mTitle=getIntent().getStringExtra("title");
        pdfUrl=getIntent().getStringExtra("pdfUrl");
    }

    @Override
    protected void initTopBar() {
        setTitle(mTitle);
        enableNavLeftImg();
    }

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_res_other_detail);
    }

    @Override
    protected void initView() {
        webView = (WebView) findViewById(R.id.webview_web);
        loadPDF1();
    }
    private void loadPDF1(){
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
//        webView.getSettings().setPluginsEnabled(true);
        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.requestFocus();
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        String pdfurl = pdfUrl;
        webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdfurl);

    }
    private void loadPDF2(){
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
//        webView.getSettings().setPluginsEnabled(true);
        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.requestFocus();  //www.2cto.com
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        String pdfurl = pdfUrl;
        String data = "<iframe src='http://docs.google.com/gview?embedded=true&url="+pdfurl+"'"+" width='100%' height='100%' style='border: none;'></iframe>";
        webView.loadData(data, "text/html", "UTF-8");

    }

    @Override
    protected void initAdapter() {

    }

    @Override
    protected void initDates() {

    }

    @Override
    protected void initListener() {

    }
}
